﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Guia.Elements;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Guia.Core;
using WpfTestApplication;

namespace GuiaTest
{
    /// <summary>
    /// Summary description for ComboBoxItemTest
    /// </summary>
    [TestClass]
    public class ComboBoxItemTest : AbstractWindowTest
    {
        public ComboBoxItemTest()
        {
        }

        protected override Type TestWindowType()
        {
            return typeof(ComboBoxTestWindow);
        }

        protected override string TestWindowName()
        {
            return "ComboBoxTestWindow";
        }

        [TestMethod]
        public void TestSelect()
        {
            ComboBox comboBox = window.Get<ComboBox>("comboBox1");
            ComboBoxItem item = comboBox.GetItem("item 2");
            ComboBoxItem item2 = comboBox.GetItem("item 3");
            Assert.IsFalse(item.IsSelected);
            item.Select();
            Assert.IsTrue(item.IsSelected);
            item.Unselect();
            Assert.IsFalse(item.IsSelected);
            item.Select();
            Assert.IsTrue(item.IsSelected);
            item2.Select();
            Assert.IsTrue(item2.IsSelected);
            Assert.IsFalse(item.IsSelected);
        }

        [TestMethod]
        public void TestSetIsSelected()
        {
            ComboBox comboBox = window.Get<ComboBox>("comboBox1");
            ComboBoxItem item = comboBox.GetItem("item 3");
            item.IsSelected = false;
            Assert.IsFalse(item.IsSelected);
            item.IsSelected = true;
            Assert.IsTrue(item.IsSelected);
            item.IsSelected = true;
            Assert.IsTrue(item.IsSelected);
            item.IsSelected = false;
            Assert.IsFalse(item.IsSelected);
        }

        [TestMethod]
        public void TestGetTextValue()
        {
            ComboBox comboBox = window.Get<ComboBox>("comboBox1");
            ComboBoxItem item = comboBox.GetItem("item 1");
            Assert.AreEqual("item 1",item.TextValue);
        }
    }
}
